from django.db import models


# Create your models here.
class Host(models.Model):
    id = models.AutoField(primary_key=True)
    hostalias = models.CharField(max_length=128, verbose_name="主机名别名")
    hostname = models.CharField(null=True, max_length=128, verbose_name="主机名")
    port = models.IntegerField(verbose_name="端口")
    ip = models.CharField(max_length=16, verbose_name="IP地址")
    username = models.CharField(max_length=128, verbose_name="可登录用户名")
    mode_choices = ((0, "密码登录"), (1, "密钥登录"))
    mode = models.IntegerField(choices=mode_choices, verbose_name="登录方式")
    pwd = models.TextField(verbose_name="登录密码/密钥")


class HostVideo(models.Model):
    id = models.AutoField(primary_key=True)
    createtime = models.DateTimeField(auto_now_add=True, verbose_name='开始时间')
    endtime = models.DateTimeField(null=True, verbose_name='结束时间')
    operator = models.CharField(max_length=32, verbose_name='操作人')
    path = models.TextField(default='', verbose_name='保存路径')
    host = models.ForeignKey(to='Host', to_field='id', on_delete=models.CASCADE)
